// @ts-nocheck

import { ThrottleSettings } from "lodash";

// 构建一个查找规则，找到后将 左边 和 右边 留起来 ${infer L}${C}${infer R}   ${F}${L}${RC} , R 需要继续递归
// type Replace<T, H, C> = H extends T ? (H extends `${L}${M}${R}` ? Replace<`${L}${C}${R}`,H,C> : T) : T;
type Replace<T, H, C> = 
T extends ""
  ? H extends ""
    ? C
    : T
  : H extends ""
  ? `${C}${T}`
  : T extends `${infer L}${H}${infer R}`
  ? Replace<`${L}${C}${R}`, H, C>
  : T;

type a1 = Replace<"ha ha ha", "ha", "he">;
type a2 = Replace<"jw", "jw", "jiangwen">;
type a3 = Replace<"a", "", "jiangwen">;//jiangwena
type a4 = Replace<"", "", "jiangwen">;
type a5 = Replace<"", "22", "jiangwen">;

// 下次实现, 尝试实现以下replace
export {};
